home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 September
/
Macworld (1997-09).dmg
/
Shareware World
/
Utilities
/
Text Processing
/
Alpha
/
Tcl
/
SystemCode
/
modes.tcl
< prev
next >
Wrap
Text File
|
1997-04-02
|
28KB
|
996 lines
# (nowrap)
# New modes can be specified by appending to the following vars. (nowrap)
# are no longer any procs such as 'setTextMode' etc.
#================================================================================
# The next two procs are called by Alpha to handle the mode flags popup menu.
#================================================================================
proc getModeValuesAlpha {} {
global showInvisibles
getWinInfo blah
lappend m "Mac" [expr {$blah(platform) == "mac"}]
lappend m "UNIX" [expr {$blah(platform) == "unix"}]
lappend m "IBM" [expr {$blah(platform) == "ibm"}] {(-} 0
lappend m "MPW" [expr {$blah(state) == "mpw"}]
lappend m "Think" [expr {$blah(state) == "think"}]
lappend m "None" [expr {$blah(state) == "none"}] {(-} 0
lappend m "Read Only" $blah(read-only)
lappend m "Show Invisibles" $showInvisibles {(-} 0
lappend m "Tab Size" 0
return $m
}
proc setModeVarAlpha {var} {
global mode allFlags modeVars modifiedModeVars
global ${mode}modeVars
set var [string tolower $var]
switch $var {
"unix" -
"mac" -
"ibm" { setWinInfo platform $var }
"mpw" -
"think" -
"none" { setWinInfo state $var }
"tab size" {
getWinInfo arr
if {![catch {prompt "New tab size?" $arr(tabsize)} res]} {
setWinInfo tabsize $res
}
}
"read only" {
getWinInfo b
setWinInfo read-only [expr -1 * ($b(read-only) - 1)]}
"show invisibles" {
global showInvisibles
set showInvisibles [expr 1 - $showInvisibles]
}
}
return
}
proc modeOptions {menu var} {
if {![llength [winNames]]} {
alertnote "No window!"
return
}
switch $var {
"flags" modifyModeFlags
"menus" setModeMenus
"editPrefs" editCurrentModePrefs
"loadPrefs" sourceCurrentModePrefs
"describeMode" describeMode
"change" changeModeDialog
}
}
#===============================================================================
proc changeModeDialog {} {
global mode modeMenus
set nmode [listpick -p "Mode:" -L $mode [lsort -ignore [array names modeMenus]]]
newMode $nmode
}
#================================================================================
# Can be used to add new mode-specific flags and variables (see think.tcl for example).
proc newModeVar {mode var val isFlag} {
global ${mode}modeVars modeVars allFlags $var
if {![info exists modeVars] || [lsearch $modeVars $var] < 0} {
lappend modeVars $var
}
if {![info exists ${mode}modeVars($var)]} {
set ${mode}modeVars($var) $val
if {![info exists $var]} {
set $var $val
}
}
if {$isFlag && (![info exists allFlags] || ([lsearch $allFlags $var] < 0))} {
lappend allFlags $var
}
}
#================================================================================
proc stringColorProc {flag} {
global $flag mode
if {[set $flag] == "none"} {
set $flag "foreground"
}
if {$flag == "stringColor"} {
regModeKeywords -a -s $stringColor $mode
} elseif {$flag == "commentColor"} {
regModeKeywords -a -c $commentColor $mode
} elseif {$flag == "funcColor"} {
regModeKeywords -a -f $funcColor $mode
} elseif {$flag == "bracesColor"} {
regModeKeywords -a -I $bracesColor $mode
} elseif {($flag == "keywordColor") || ($flag == "sectionColor")} {
alertnote "Change in keyword color will take effect after Alpha restarts."
return
}
centerRedraw
}
#================================================================================
proc saveVarValues {} {
global HOME modeMenus
if {[askyesno "Save variables and values to \"$HOME:alphaFlags.tcl\"?"] == "yes"} {
set lines {}
foreach m [lsort -ignore [array names modeMenus]] {
global ${m}modeVars
if {[info exists ${m}modeVars]} {
foreach v [array names ${m}modeVars] {
append lines "set ${m}modeVars($v)\t\t\{[set ${m}modeVars($v)]\}\r"
}
append lines "\r"
}
}
append lines "\r\r"
global allFlags allVars
set vars [lsort [concat $allFlags $allVars]]
eval global $vars
foreach f $vars {
append lines "set $f\t\t\{[set $f]\}\r"
}
set fd [open "$HOME:alphaFlags.tcl" "w"]
puts $fd $lines
close $fd
message "New '$HOME:alphaFlags.tcl' written."
}
}
#================================================================================
proc setWinMode name {
global winModes ModeSuffixes
set nm [file tail $name]
if {[set first [string last " <" $nm]] >= 0} {
set rname [string range $nm 0 [expr $first - 1]]
} else {
set rname $nm
}
case $rname in $ModeSuffixes
set winModes($name) $winMode
}
# Called from alphs in response to the mode popup.
proc newMode mode {
global winModes modeProcs
changeMode $mode
if {[catch {car [winNames -f]} name]} return
set winModes($name) $mode
centerRedraw
}
proc deactivateHook name {
}
proc suspendHook name {
global iconifyOnSwitch
global suspIconed
if {$iconifyOnSwitch} {
set wins [winNames -f]
set suspIconed ""
foreach win $wins {
if {![icon -f "$win" -q]} {
lappend suspIconed $win
icon -f "$win" -t
}
}
set suspIconed [lreverse $suspIconed]
}
}
set killCompilerErrors 0
proc resumeHook name {
global iconifyOnSwitch resumeRevert suspIconed killCompilerErrors
if {$killCompilerErrors} {
set wins [winNames -f]
if {[set res [lsearch $wins "*Compiler Errors*"]] >= 0} {
bringToFront [lindex $wins $res]
killWindow
}
}
if {$iconifyOnSwitch && [info exists suspIconed]} {
set wins [winNames -f]
foreach win $suspIconed {
icon -f "$win" -o
}
unset suspIconed
}
if {$resumeRevert} {
set resumeRevert 0
revert
}
}
# Handles dynamically adding and deleting window names from menu.
proc addWinName name {
global winNameToNum winMenu winNumToName
for {set i 0} {$i<100} {incr i} {
if ![info exists winNumToName($i)] {
regexp {(^\* .*|[^:]*$)} $name nm
if {$i < 10} {
addMenuItem -m -l "/$i" $winMenu "$nm"
} else {
addMenuItem -m -l "" $winMenu "$nm"
}
set winNumToName($i) $name
set winNameToNum($name) $i
return
}
}
}
proc removeWinName name {
global winNameToNum winNumToName winMenu
regsub -all {\\([][])} $name {\1} name
set num $winNameToNum($name)
unset winNumToName($num)
unset winNameToNum($name)
regexp {(^\* .*|[^:]*$)} $name nm
deleteMenuItem -m $winMenu $nm
}
proc menuWin {menu name} {
global winNameToNum
set nms [array names winNameToNum]
if {[lsearch $nms "*[quoteExpr $name]"] < 0} {
$name
return
}
foreach nm $nms {
if {[string match *[quoteExpr $name] $nm] == "1"} {
bringToFront $name
if [icon -q] { icon -f $name -o }
return
}
}
return "normal"
}
# Do not move 'displayMode' calls!
proc changeMode {newMode} {
global lastMode modeMenus dummyProc mode seenMode PREFS globalMenus_curr
set lastMode $mode
set mode $newMode
if {$lastMode == $mode} {
catch {displayMode $newMode}
return
}
global ${lastMode}modeVars
# if {[info exists ${lastMode}modeVars]} {
# foreach v [array names ${lastMode}modeVars] {
# global $v
# catch {unset $v}
# }
# }
floatShowHide off $lastMode
# Used to be after the modeVar stuff. Why?
if {[info exists dummyProc($mode)]} { $dummyProc($mode) }
global ${mode}modeVars
if {[info exists ${mode}modeVars]} {
foreach v [array names ${mode}modeVars] {
global $v
set $v [set ${mode}modeVars($v)]
}
}
if {[info exists modeMenus($lastMode)]} {
if {[info exists modeMenus($mode)]} {
set oldMenus modeMenus($mode)
} else {
set oldMenus ""
}
foreach m $modeMenus($lastMode) {
if {([lsearch $globalMenus_curr $m] < 0) && ([lsearch $oldMenus $m] < 0)} {
global $m
catch {removeMenu [set $m]}
}
}
}
if {[info exists modeMenus($mode)]} {
foreach m $modeMenus($mode) {
catch {$m}
global $m
catch {insertMenu [set $m]}
}
}
if {![info exists seenMode($mode)]} {
if {($mode != "") && [file exists "$PREFS:${mode}Prefs.tcl"]} {
if {[catch {source "$PREFS:${mode}Prefs.tcl"}]} {
alertnote "Your preferences file '${mode}Prefs.tcl has an error."
} else {
set seenMode($mode) 1
}
}
}
floatShowHide on $mode
catch {displayMode $newMode}
}
proc setModeMenus {} {
global mode modeMenus menus modifiedModeMenus globalMenus_curr
set ms [listpick -p "Pick menus for mode '$mode':" -l -L $modeMenus($mode) [lsort $menus]]
set modeMenus($mode) $ms
lappend modifiedModeMenus $mode
foreach m $menus {
if {[lsearch $globalMenus_curr $m] < 0} {
global $m
catch {removeMenu [set $m]}
}
}
foreach m $ms {
global $m
catch {$m}
catch {insertMenu [set $m]}
}
}
#=============================================================================
# Hook procs recognized: "openHook", "closeHook", "activateHook", "deactivateHook",
# "suspendHook", "saveasHook", "saveHook", and "resumeHook".
#=============================================================================
if {![info exists winActive]} {set winActive ""}
# Event hooks - set specific modes when files opened.
proc openHook name {
global winModes autoMark mode screenHeight screenWidth forceMainScreen recentFiles recentFilesCount
changeMode $winModes($name)
if {$name == {*Toolserver shell*}} startMPW
regsub -all {\\([][])} $name {\1} nm
addWinName $nm
message ""
if {![catch {getFileInfo $name info}]} {
if {$info(creator) == {ttxt}} {
setWinInfo dirty 0
}
if {$info(type) == {ttro}} {
catch {setWinInfo read-only 1}
message "Read-only!"
}
}
global ${mode}modeVars
if {$forceMainScreen} {
set geo [getGeometry]
set l [lindex $geo 0]; set t [lindex $geo 1]; set w [lindex $geo 2]; set h [lindex $geo 3];
if {($l < 0) || ($t < 35) || ([expr $l + $w] > $screenWidth) || ([expr $t + $h + 18] > $screenHeight)} {
singlePage
}
}
getWinInfo arr
if {[info exists ${mode}modeVars(autoMark)] && [set ${mode}modeVars(autoMark)] && !$arr(read-only) && ![llength [getNamedMarks -n]]} {
markFile
}
if {[string match "*Preferences*defs.tcl" $name]} {setWinInfo read-only 1}
pushRecent $name
}
# full pathname, called *before* file actually saved
proc saveHook name {
global backup backExtension backDir mode winModes
if {($mode == "C") || ($mode == "Pasc") || ($mode == "C++")} {catch {modified}}
if {$winModes($name) == "HTML"} {catch {htmlLastModified $name}}
if ($backup) {
set dir [uplevel #0 {substituteVars $backDir}]
if {![string length $dir]} {
set dir [file dirname $name]
}
if {![file exists $dir]} {
if {[askyesno "Create backup dir '$dir'?"] == "yes"} {
mkdir $dir
}
}
catch {rm $dir:[file tail $name]$backExtension}
catch {cp $name $dir:[file tail $name]$backExtension}
}
}
# full pathname, called *after* file saved.
proc savePostHook name {
global savePostHooks
if {[info exists savePostHooks]} {
foreach hook $savePostHooks {
catch {$hook $name}
}
}
}
proc revertToBackup {} {
global backup backExtension backDir winModes
set fname [car [winNames -f]]
set dir [uplevel #0 {substituteVars $backDir}]
set bname "$dir:[file tail $fname]$backExtension"
if {![file exists $bname]} {
message "Backup file '$bname' does not exist"
return
}
if {[askyesno "Revert to backup dated '[join [mtime [file mtime $bname]]]'?"] == "yes"} {
killWindow
edit $bname
saveAs -f $fname
}
}
# Clean up the mark stack.
proc closeHook name {
global markStack winModes winActive
unset winModes($name)
if [llength $markStack] {
set markStack [removePat $markStack $name*]
}
removeWinName $name
if {[set ind [lsearch $winActive $name]] >= 0} {
set winActive [lreplace $winActive $ind $ind]
}
catch {unset winModes($name)}
if {![llength [winNames]]} {
changeMode {}
}
}
proc saveasHook {oldName newName} {
global winModes winActive
if {$oldName == $newName} return
removeWinName $oldName
addWinName $newName
setWinMode $newName
changeMode $winModes($newName)
pushRecent $newName
if {$winModes($newName) == "HTML"} {catch {htmlLastModified $newName}}
if {[set ind [lsearch $winActive $oldName]] >= 0} {
set winActive [lreplace $winActive $ind $ind]
}
set winActive [linsert $winActive 0 $newName]
catch {unset winModes($oldName)}
}
if {![info exists actives]} {set actives 0}
# and, install a new 'winActive' patch , to 'activateHook':
proc activateHook name {
global winModes winActive
if {![info exists winModes($name)]} {
setWinMode $name
}
changeMode $winModes($name)
if {[set ind [lsearch $winActive $name]] == -1} {
set winActive [linsert $winActive 0 $name]
return
}
if {$ind >= 1} {
set winActive [lreplace $winActive $ind $ind]
set winActive [linsert $winActive 0 $name]
}
}
proc dirtyHook {name dirty} {
global winMenu
markMenuItem $winMenu [file tail $name] $dirty "◊"
}
proc quitHook {} {
global quitHooks PREFS
if {[file exists "$PREFS:ftpTmp"]} {
catch {rm "$PREFS:ftpTmp:*"}
}
saveModifiedVars
if {[info exists quitHooks]} {
foreach item $quitHooks {
$item
}
}
}
proc saveModifiedVars {} {
global modifiedVars modifiedModeVars modifiedArrVars modifiedModeMenus modeMenus prefDefs recentFilesSave recentFiles
if {[llength $modifiedVars] || [llength $modifiedArrVars] || [llength $modifiedModeVars] || [llength $modifiedModeMenus]} {
foreach f [removeDups $modifiedModeMenus] {
addArrDef modeMenus $f $modeMenus($f)
}
foreach f [removeDups $modifiedArrVars] {
global $f
foreach ind [array names $f] {
addArrDef $f $ind [set ${f}($ind)]
}
}
foreach f [removeDups $modifiedVars] {
global $f
addDef $f [set $f]
}
foreach f [removeDups $modifiedModeVars] {
set nm [lindex $f 0]
set mode [lindex $f 1]
global $mode
addArrDef [set mode] $nm [set [set mode]($nm)]
}
}
if {[info exists recentFiles]} {
addDef recentFilesSave $recentFiles
}
set modifiedVars {}
set modifiedArrVars {}
set modifiedModeVars {}
set modifiedModeMenus {}
}
#================================================================================
proc describeMode {} {
global mode ModeSuffixes modeMenus
global ${mode}modeVars
set text "\r\tMODE $mode\r\r"
set suffs ""
set first 1
foreach suf $ModeSuffixes {
if {([llength $suf] == 3) && ([lindex $suf 1] == "winMode") && ([lindex $suf 2] == $mode)} {
if {$first} {
lappend suffs $last
set first 0
} else {
append suffs ", $last"
}
}
set last $suf
}
append text "Mode filepats: $suffs\r\r"
set first 1
append text "Mode menus: "
if {[info exists modeMenus($mode)]} {
foreach m $modeMenus($mode) {
if $first {
set first 0
lappend text $m
} else {
append text ", $m"
}
}
}
append text "\r\r"
append text "Mode-specific variables:\r"
if {[info exists ${mode}modeVars]} {
foreach v [lsort [array names ${mode}modeVars]] {
append text [format "\t%-20s: \"%s\"\r" $v [set ${mode}modeVars($v)]]
}
}
set etext "\rMode-independent bindings:\r"
append text "\rMode-specific bindings:\r"
foreach b [split [bindingList] "\r"] {
set lst [lindex $b end]
if {$lst == $mode} {
append text "\t$b\r"
} elseif {[lsearch [lsort -ignore [array names modeMenus]] $lst] < 0} {
append etext "\t$b\r"
}
}
new -n "* <$mode> MODE *"
insertText $text$etext
goto 0
setWinInfo dirty 0
}
proc globalOptions {menu item {is_mode ""}} {
global flagPrefs varPrefs maxT tcl_var_procs modifiedVars modeMenus mode
updateMisc
if {[string length $is_mode]} {
set args {}
set nvars [llength $item]
for {set i 0} {$i < $nvars} {incr i 10} {
lappend args [list "Page [expr 1+(${i}/10)] of ${is_mode}" $menu [lrange $item $i [expr $i+9]]]
set menu ""
}
} else {
if {$item == "menus"} {
global menus globalMenus_curr
set globalMenus_curr [listpick -p "Select global menus:" -l -L $globalMenus_curr [lsort -ignore $menus]]
foreach m $menus {
global $m
if {[info exists $m]} {
catch "removeMenu [set $m]"
}
}
lappend modifiedVars globalMenus_curr
foreach m $globalMenus_curr {
catch $m
insertMenu [set $m]
}
if {[info exists modeMenus($mode)]} {
foreach m $modeMenus($mode) {
catch $m
insertMenu [set $m]
}
}
return
}
if {$item != "flags"} {
return [$item]
}
set args {}
foreach nm [array names flagPrefs] {
lappend args [list $nm $flagPrefs($nm) $varPrefs($nm)]
}
}
set left 20
set height [expr 500 + 60]
set names {}
set maxT 0
foreach arg [lsort $args] {
if {[llength $arg] != 3} {error "Bad structure"}
lappend names [lindex $arg 0]
set flags [lindex $arg 1]
set vars [lindex $arg 2]
append editItems " " $flags " " $vars
append cmd " -n \{[lindex $arg 0]\} " [dialSet $flags $vars]
}
set height [expr $maxT + 30]
set buttons [concat -b OK $left [expr $height-30] [expr $left + 60] [expr $height-10] -b Cancel [expr $left + 100] [expr $height-30] [expr $left + 160] [expr $height-10]]
global blah
set res [eval [concat dialog -w 480 -h $height -t "Preferences:" 60 10 140 30 $buttons [list -m [concat [list [lindex $names 0]] $names] 150 10 405 30] $cmd]]
set changed {}
if {[lindex $res 0]} {
set res [lrange $res 3 end]
if {[string length $is_mode]} {
return $res
}
foreach item $editItems {
set val [lindex $res 0]
set res [lrange $res 1 end]
global $item
if {[set $item] != $val} {
set $item $val
if {[info exists tcl_var_procs($item)]} {
$tcl_var_procs($item) $item
}
lappend modifiedVars $item
}
}
} else {
error "Cancel chosen"
}
}
proc modifyModeFlags {{title ""}} {
global mode invisibleModeVars modifiedModeVars
global ${mode}modeVars
global allFlags tcl_var_procs
global ${mode}invisibleModeVars
if {$mode == ""} {
alertnote "No mode set!"
return
}
if {$title == ""} {
set title "Preferences for '${mode}' mode"
}
# check for mode specific proc
if {[info commands ${mode}modifyFlags] != ""} {${mode}modifyFlags; return}
set flags {}
set vars {}
if {[info exists ${mode}modeVars]} {
foreach v [lsort [array names ${mode}modeVars]] {
if {[info exists invisibleModeVars($v)] \
|| [info exists ${mode}invisibleModeVars($v)]} continue
if {[lsearch $allFlags $v] >= 0} {
lappend flags $v
} else {
lappend vars $v
}
}
set flags [lsort $flags]
set vars [lsort $vars]
if {[llength $vars] > 10 } {
set res [globalOptions $flags $vars $title]
} else {
set res [modeDialog $flags $vars $title]
}
foreach flag [concat $flags $vars] {
global $flag
set val [lindex $res 0]
set res [lrange $res 1 end]
if {[set $flag] != $val} {
set $flag $val
set ${mode}modeVars($flag) $val
lappend modifiedModeVars [list $flag ${mode}modeVars]
if {[info exists tcl_var_procs($flag)]} {
$tcl_var_procs($flag) $flag
}
}
}
updateSuffixes
}
}
proc modifyModeString {flag} {
global stringColor mode
regModeKeywords -a -s $stringColor $mode
centerRedraw
}
# Suffixes used to initially determine mode for new window.
proc updateSuffixes {} {
global ModeSuffixes modeMenus filepats
set ModeSuffixes { default { set winMode Text } }
foreach m [lsort -ignore [array names modeMenus]] {
if {[info exists filepats($m)]} {
lappend ModeSuffixes $filepats($m) "set winMode $m"
}
}
}
#===============================================================================
proc addMode {m dummy suffs menus} {
global dummyProc modeMenus filepats
set modeMenus($m) $menus
if {[string length $dummy]} {set dummyProc($m) $dummy}
set filepats($m) $suffs
}
proc addMenu {m} {
global menus
if { ![info exists menus] || [lsearch -exact $menus $m] == -1 } {
lappend menus $m
}
}
#===============================================================================
####################################
# #
# A Few Small Mode Definitions #
# #
####################################
if !$alphaLite {
addMode MPW {} {"*Toolserver\ *"} {}
addMode Diff {} {} {}
addMode PS {} {*.ps} {}
newModeVar PS prefixString {% } 0
set PSKeyWords {
def begin end dict load
exec if ifelse for repeat loop exit stop stopped countexecstack execstack quit start
gsave grestore grestoreall initgraphics
newpath erasepage fill eofill stroke image imagemask showpage copypage
}
if {[info exists PSwords]} {set PSKeyWords [concat $PSKeyWords $PSwords]}
regModeKeywords -e {%} -m {/} -c red -k blue PS $PSKeyWords -i "\}" -i "\{" -i {[} -i {]} -I green
unset PSKeyWords
}
#================================================================================
addMode Brws dummyBrws {} {}
#================================================================================
addMode Text {} {default} {}
newModeVar Text leftFillColumn {0} 0
newModeVar Text suffixString { <--} 0
newModeVar Text prefixString {> } 0
newModeVar Text fillColumn {75} 0
newModeVar Text wordWrap {1} 1
newModeVar Text wordBreak {\w+} 0
newModeVar Text wordBreakPreface {(\W)} 0
newModeVar Text wrapBreak {[\w_]+} 0
newModeVar Text wrapBreakPreface {([^\w_])} 0
newModeVar Text autoMark 0 1
##############################
# #
# Things done at startup #
# #
##############################
# For quithook
set modifiedVars {}
set modifiedArrVars {}
set modifiedModeVars {}
set modifiedModeMenus {}
# ???
set modeVars {funcExpr wrapBreakPreface wrapBreak wordBreakPreface wordBreak}
# 'mode' is nothing when we start up.
set mode {}
set lastMode 0
set reverting {}
# Used on modified mode flags.
set tcl_var_procs(stringColor) "stringColorProc"
set tcl_var_procs(commentColor) "stringColorProc"
set tcl_var_procs(keywordColor) "stringColorProc"
set tcl_var_procs(funcColor) "stringColorProc"
set tcl_var_procs(sectionColor) "stringColorProc"
set tcl_var_procs(bracesColor) "stringColorProc"
##############################################################
# #
# Used to split flags over different preferences panels. #
# #
##############################################################
set flagPrefs(Backups) {backup}
set varPrefs(Backups) {backDir backExtension}
set flagPrefs(Gui) {blinkingCursor blockCursor coloring dragAndDrop iconifyOnSwitch intelCutPaste lockStatus showInvisibles smallMenuFont sortFuncsMenu tearoffMenus }
set varPrefs(Gui) {defaultFont fontSize tabSize}
set flagPrefs(Printer) {printHeader printHeaderFullPath printHeaderTime}
set varPrefs(Printer) {bottomMargin printerFont printerFontSize topMargin leftMargin}
set flagPrefs(Tags) {}
set varPrefs(Tags) {funcPar tagFile}
set flagPrefs(Window) {autoHScroll forceMainScreen horScrollBar moveInsertion powerThumb sortedIsDefault}
set varPrefs(Window) {defHeight defLeft defTop defWidth }
set flagPrefs(Tiling) {}
set varPrefs(Tiling) {numWinsToTile horMargin tileHeight tileProportion tileLeft tileMargin tileTop tileWidth }
set flagPrefs(Wrapping) {}
set varPrefs(Wrapping) {fillColumn leftFillColumn paraColumn wrapLow wrapHigh}
proc updateMisc {} {
uplevel #0 {
set flagPrefs(Miscellaneous) {}
foreach f $allFlags {
if {([lsearch $modeVars $f] < 0) && ([lsearch $flagPrefs(Tiling) $f] < 0) && ([lsearch $flagPrefs(Backups) $f] < 0) && ([lsearch $flagPrefs(Gui) $f] < 0) && ([lsearch $flagPrefs(Printer) $f] < 0) && ([lsearch $flagPrefs(Tags) $f] < 0) && ([lsearch $flagPrefs(Window) $f] < 0) && ([lsearch $flagPrefs(Wrapping) $f] < 0)} {
lappend flagPrefs(Miscellaneous) $f
}
}
set varPrefs(Miscellaneous) {}
foreach f $allVars {
if {([lsearch $modeVars $f] < 0) && ([lsearch $varPrefs(Tiling) $f] < 0) && ([lsearch $varPrefs(Backups) $f] < 0) && ([lsearch $varPrefs(Gui) $f] < 0) && ([lsearch $varPrefs(Printer) $f] < 0) && ([lsearch $varPrefs(Tags) $f] < 0) && ([lsearch $varPrefs(Window) $f] < 0) && ([lsearch $varPrefs(Wrapping) $f] < 0)} {
lappend varPrefs(Miscellaneous) $f
}
}
}
}
#####################################################
# #
# Find out which modes and menus are out there. #
# #
#####################################################
set startingUp 1
if {![catch {glob "$HOME:Tcl:Modes:*Mode.tcl"} files]} {
foreach f $files {
if {[catch {source $f}]} {
lappend problems [file tail $f]
}
}
}
if {![catch {glob "$HOME:Tcl:Menus:*Menu.tcl"} files]} {
foreach f $files {
if {[catch {source $f}]} {
lappend problems [file tail $f]
}
}
}
if {[info exists problems]} {
alertnote "Problems loading files '$problems'"
unset problems
}
if {[info exists menus]} {
set menus [removeDups $menus]
}
set startingUp 0
foreach m [lsort -ignore [array names modeMenus]] {
addMenuItem -m modePrefs $m
}
addMode Text {} {} {}
updateSuffixes